from collections import OrderedDict

from django import http
from django.shortcuts import render

# Create your views here.
from django.views import View

from apps.goods.models import GoodsChannel
from apps.index.models import ContentCategory
from utils.get_category import get_categories


class IndexView(View):
    def get(self, request):
        categories_dict = get_categories()

        contents = {}
        content_categories = ContentCategory.objects.all()
        for temp in content_categories:
            contents[temp.key] = temp.content_set.filter(status=True).order_by('sequence')
        context = {
            'categories': categories_dict,
            'contents': contents,
        }

        return render(request, 'base_index.html', context=context)
